package com.voole.wideget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.GridView;

import com.facebook.rebound.BaseSpringSystem;
import com.facebook.rebound.SimpleSpringListener;
import com.facebook.rebound.Spring;
import com.facebook.rebound.SpringSystem;
import com.facebook.rebound.SpringUtil;

public class VGridView extends GridView {

	private Spring mScaleSpring;
	private final BaseSpringSystem mSpringSystem = SpringSystem.create();
	private final ExampleSpringListener mSpringListener = new ExampleSpringListener();
	public VGridView(Context context) {
		super(context);
		Vinit();
	}

	public VGridView(Context context, AttributeSet attrs) {
		super(context, attrs);
		Vinit();
	}

	public VGridView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		Vinit();
		
	}
	private void Vinit()
	{
		mScaleSpring = mSpringSystem.createSpring();
	}
	
	@Override
	protected void onDetachedFromWindow() {
		mScaleSpring.removeListener(mSpringListener);
		super.onDetachedFromWindow();
	}
	private void onScale(float x,float y){
		
	}
	
	private class ExampleSpringListener extends SimpleSpringListener {
		@Override
		public void onSpringUpdate(Spring spring) {
			float mappedValue = (float) SpringUtil.mapValueFromRangeToRange(spring.getCurrentValue(), 0, 1, 1, 2);
			onScale(mappedValue, mappedValue);
		}
	}

}
